home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_17_1987_Transactor_Publishing.d64 / textscan cp_m < prev    next >
Text File  |  2023-02-26  |  21KB  |  647 lines

  1. ;-------------------------------------------------
  2. ; "TEXT SCAN" FOR CP/M+ ON THE C128
  3. ; Aubrey Stanley, Nov 1986
  4. ;-------------------------------------------------
  5. ;
  6.         maclib  z80     ;Z80 macro library
  7.         org     100h    ;Start address
  8. ; CP/M Functions
  9. boot    equ     0       ;Warm start
  10. bdos    equ     5       ;CP/M Function Vector
  11. dciof   equ     6       ;Direct console
  12. printf  equ     9       ;Print string
  13. coninf  equ     10      ;Read console buffer
  14. openf   equ     15      ;Open file
  15. closef  equ     16      ;Close file
  16. readf   equ     20      ;Read sequential
  17. sdmaf   equ     26      ;Set DMA address
  18. msecf   equ     44      ;Multi-sector I/O
  19. sconm   equ     109     ;Set console mode
  20. sdlmf   equ     110     ;Set output delimiter
  21. ;
  22. ; File Control Block
  23. fcb     equ     5ch
  24. fcbex   equ     fcb+12
  25. fcbcr   equ     fcb+32
  26. ;
  27. ; Console Buffer for Find string
  28. dmabuf  equ     80h
  29. mx      equ     dmabuf  ;Max chars
  30. nc      equ     mx+1    ;Num chars
  31. rchar   equ     nc+1    ;Char string
  32. ;
  33. ; Character equates
  34. rawinp  equ     0ah     ;Raw input mode
  35. eomc    equ     1ah     ;End of file
  36. cr      equ     0dh     ;Carriage ret
  37. lf      equ     0ah     ;Line feed
  38. tabc    equ     09h     ;Tab
  39. bell    equ     07h
  40. ;
  41. ; Decoded values for C128 keys
  42. period  equ     24      ; . key
  43. plus    equ     28      ; +
  44. minus   equ     27      ; -
  45. endof   equ     29      ; Cur down
  46. bgnof   equ     30      ; Cur up
  47. nscrol  equ     32      ; No scroll
  48. number  equ     31      ; 0-9
  49. alt     equ     33      ; Alt
  50. tab     equ     26      ; Tab
  51. enter   equ     25      ; Enter
  52. help    equ     34      ; Help
  53. ;
  54. ; Offsets for variables on the IX register
  55. scroly  equ     0       ; Scroll mode 
  56. stop    equ     1       ; Stop scroll
  57. dir     equ     2       ; Current direction
  58. lmit    equ     3       ; Limit reached
  59. lnum    equ     4       ; Line numbering on
  60. double  equ     5       ; Double 0-9 values
  61. cnt1    equ     6       ; Current number for scroll
  62. cnt2    equ     7       ; Number of lines scrolled
  63. count   equ     8       ; General purpose
  64. ;
  65. ;--------------------------------------------
  66. chksum: ;CHECKSUMS your code - 
  67.         ;Can be DELETED when all is well
  68.         lxi     b,progend-start ;Count to check
  69.         lxiy    start           ;From sstart
  70.         lxi     h,9170h         ;Checksum excess
  71.         mvi     d,0
  72. chks:   ldy     e,0             ;Check loop
  73.         dad     d               ;...adds bytes
  74.         inxiy
  75.         dcx     b
  76.         mov     a,b
  77.         ora     c
  78.         jrnz    chks
  79.         mov     a,l             ;Should
  80.         ora     h               ;...be 0
  81.         jrz     start           ;Good code
  82.         mvi     c,dciof         ;Bad code
  83.         lxi     d,'?'           ;...print ?
  84.         call    bdos            ;...and
  85.         ret                     ;...exit
  86. ;END OF CHECKSUM CODE -
  87. ;-----------------------------------------------
  88. ;
  89. start:  ;Set stack and open file
  90.         sspd    oldsp
  91.         lxi     sp,stktop
  92.         xra     a               ;Init fcb
  93.         sta     fcbex
  94.         sta     fcbcr
  95.         lxi     d,fcb
  96.         mvi     c,openf
  97.         call    bdos            ;Open
  98.         ora     a
  99.         jrz     read
  100.         lxi     d,opnerr        ;Bad open
  101.         mvi     c,printf
  102.         call    bdos
  103. finis:  ;restore stack and exit
  104.         lspd    oldsp
  105.         ret
  106. ;
  107. read:   ;read file
  108.         lxix    pflags          ;Print flags base
  109.         lxi     h,0             ;Init sector count
  110.         shld    line
  111.         mvi     e,128           ;128 sectors to read
  112.         stx     e,lmit          ;Save for rloop
  113.         mvi     c,msecf
  114.         call    bdos            ;Set multisectors
  115.         mvix    3,count         ;3 reads
  116.         lxi     d,fbegin        ;Start of read area
  117.         call    rloop           ;Read up to 48K
  118.         ora     a               ;Check end of file
  119.         jrnz    close           ;...yes!
  120.         push    d               ;Save dma address
  121.         mvi     e,48            ;Read 48 more sectors
  122.         stx     e,lmit          ;Save for rloop
  123.         mvi     c,msecf
  124.         call    bdos            ;Set multisectors
  125.         pop     d
  126.         mvix    1,count         ;1 read
  127.         call    rloop           ;Read up to 6K more
  128. close:  lxi     d,fcb
  129.         mvi     c,closef        ;Close
  130.         call    bdos
  131. ;
  132. bytes:  ;Calculate total chars
  133.         lhld    line            ;Total sectors
  134.         mvi     b,7             ;Count
  135. byte10: dad     h               ;Double value
  136.         dcr     b               ;...7 times
  137.         jrnz    byte10
  138.         lxi     d,fbegin        ;Start
  139.         dad     d               ;End
  140.         mvi     a,eomc
  141. eom:    dcx     h               ;Find last char
  142.         cmp     m
  143.         jrz     eom
  144.         mov     a,m
  145.         inx     h
  146.         cpi     lf
  147.         jrz     eom10
  148.         mvi     m,cr            ;CR/LF at end
  149.         inx     h
  150.         mvi     m,lf
  151.         inx     h
  152. eom10:  mvi     m,eomc          ;End of file char
  153.         shld    fend            ;End of file address
  154.         inx     h
  155.         shld    linbuf          ;Line buffer address
  156.         jmp     print           ;output routine
  157. ;
  158. rloop:  ;Reads multisectors and keeps count
  159.         push    d               ;Save dma address
  160.         mvi     c,sdmaf
  161.         call    bdos            ;Set dma address
  162.         lxi     d,fcb
  163.         mvi     c,readf
  164.         call    bdos            ;Read multisectors
  165.         cpi     2               ;Bad error?
  166.         jrc     rlp5            ;...no!
  167. ;
  168. badr:   ;Error on read
  169.         lxi     d,rderr
  170.         mvi     c,printf
  171.         call    bdos
  172.         lxi     d,fcb
  173.         mvi     c,closef        ;Close
  174.         call    bdos
  175.         jmp     finis
  176. ;
  177. rlp5:   ora     a               ;More to read?
  178.         jrnz    rlp6            ;No!
  179.         ldx     h,lmit          ;Store full count
  180. rlp6:   mov     e,h             ;# sectors read
  181.         mvi     d,0
  182. ;
  183. rlp10:  ;sum total sectors so far
  184.         lhld    line            ;Current count
  185.         dad     d               ;Add in sectors read
  186.         shld    line
  187.         pop     d
  188.         cpi     1               ;End of file?
  189.         rz                      ;Yes!
  190.         mvi     a,64            ;Next dma address
  191.         add     d               ;...up 128 sectors
  192.         mov     d,a             ;...or 16K in DE
  193.         dcrx    count           ;Any more reads?
  194.         jrnz    rloop           ;Yes, continue reading
  195.         xra     a               ;more bytes status
  196.         ret
  197. ;
  198. print:  ;Initialize for printing file
  199.         mvi     a,40            ;40 char buffer
  200.         sta     mx              ;...for Find
  201.         mvix    nscrol,stop     ;To scroll
  202.         mvix    0,scroly        ;Not continuous
  203.         mvix    0,double        ;dont double count
  204.         mvix    plus,dir        ;Direction
  205.         mvix    0,lnum          ;No line numbers
  206.         mvix    24,cnt1         ;24 lines a time
  207.         lxi     h,fbegin-2      ;Store beginning
  208.         mvi     m,eomc          ;...of file
  209.         inx     h               ;...preamble
  210.         mvi     m,lf
  211.         inx     h
  212.         shld    line            ;Address of
  213.         lxi     h,1             ;...first line
  214.         shld    lino            ;...line number
  215. pr10:   call    getln           ;Get next line
  216.         jrnz    pr10            ;...until limit
  217.         lhld    lino            ;Store last line's
  218.         shld    endln           ;...line number
  219.         lxi     h,fbegin        ;Start with
  220.         shld    line            ;...first line
  221.         lxi     h,1
  222.         shld    lino
  223.         mvix    0,lmit          ;Clear limit
  224.         mvi     e,lf            ;Set LF
  225.         mvi     c,sdlmf         ;...delimiter
  226.         call    bdos            ;...for output
  227.         lxi     d,rawinp        ;Console mode
  228.         mvi     c,sconm         ;...set
  229.         call    bdos
  230.         call    clear           ;Clear screen
  231. ;
  232. ploop:  ;Print loop controls output to screen
  233.         ldx     a,cnt1          ;Lines to output
  234.         stx     a,cnt2
  235. plp10:  call    getkey          ;Conditions output
  236.         lxi     d,sfwd          ;Forward
  237.         ldx     a,dir           ;...direction
  238.         ora     a
  239.         jrnz    plp12
  240.         lxi     d,sbak          ;Backward
  241. plp12:  mvi     c,printf        ;Outp insert or delete
  242.         call    bdos            ;...line string
  243.         ldx     a,lnum          ;Check line
  244.         ora     a               ;...numbering
  245.         cnz     numout          ;...on and output num
  246.         call    buflin          ;Expand line in buffer
  247.         lded    linbuf          ;Line buffer address
  248.         mvi     c,printf        ;Output
  249.         call    bdos            ;...line
  250. plp18:  call    getln           ;Get next line pointer
  251.         ldx     a,lmit          ;Check file limit
  252.         ora     a               ;...reached
  253.         jrz     plp20           ;No!
  254.         mvix    0,stop          ;Stop output
  255.         jr      plp10
  256. plp20:  dcrx    cnt2            ;Count down
  257.         jrnz    plp10
  258.         mvix    0,stop          ;Count expired..stop
  259.         jr      ploop
  260. ; Actions key input...loops until Stop cleared
  261. getkey: ;input routine
  262.         call    kscan           ;Scan 128 keys
  263.         ora     a
  264.         jrz     gkg60           ;No press
  265.         cpi     number          ;Line Feed?
  266.         jrnz    gk20
  267.         xorx    lnum            ;Toggle line
  268.         stx     a,lnum          ;...number flag
  269.         jr      gk48
  270. ;
  271. gk20:   cpi     tab             ;Tab?
  272.         jrnz    gk22
  273.         call    upln            ;Advance line
  274.         jr      gk48            ;...position
  275. gk22:   cpi     alt             ;Alt?
  276.         jrnz    gk30
  277.         xorx    double          ;Toggle
  278.         stx     a,double        ;...double flag
  279.         call    sound           ;Sound bell
  280.         jr      gkg60
  281. ;
  282. gk30:   cpi     enter           ;Enter?
  283.         jrz     gk48            ;Yes!
  284.         jrnc    gk36            ;Not a number key!
  285.         cpi     11              ;Period key..24 lines?
  286.         jrnc    gk34            ;Yes!
  287.         mov     b,a
  288.         ldx     a,double        ;Double flag?
  289.         ora     a
  290.         mov     a,b
  291.         jrz     gk34
  292.         add     a               ;Double 1-(1)0
  293. gk34:   stx     a,cnt1          ;New output count
  294.         jr      gk48
  295. gk36:   cpi     nscrol          ;No Scroll?
  296.         jrnz    gk40
  297.         xorx    scroly          ;Toggle
  298.         stx     a,scroly        ;...scroll flag
  299. gkg60:  jr      gk60
  300. ;
  301. gk40:   cpi     bgnof           ;Curs Up?
  302.         jrnz    gk44
  303.         mvix    plus,dir        ;Scroll up direction
  304.         lxi     h,fbegin        ;First line
  305.         shld    line            ;...address
  306.         lxi     h,1             ;Line 1
  307.         jr      gk46
  308. gk44:   cpi     endof           ;Curs Down?
  309.         jrnz    gk50
  310.         mvix    0,dir           ;Scroll down dir
  311.         lhld    fend            ;End of file address
  312.         lxi     b,2000          ;Max length of line
  313.         call    upm02           ;Go back 1 to last line
  314.         lhld    endln           ;Last line number
  315. gk46:   shld    lino            ;Line number
  316. gk47:   call    clear           ;Clear screen
  317.         mvix    0,lmit          ;Clear limit condition
  318. gk48:   ldx     a,cnt1          ;New count
  319.         stx     a,cnt2
  320.         jr      gk64
  321. ;
  322. gk50:   cpi     help            ;Help?
  323.         jrnz    gk52
  324.         call    find            ;Find input string
  325.         jrnz    gk47
  326.         mvix    1,cnt2          ;1 line outut
  327.         mvix    0,scroly        ;Clear scroll flag
  328.         jr      gk64
  329. gk52:   cpi     minus           ;Minus?
  330.         jrnz    gk54            ;No, must be Plus!
  331.         xra     a
  332. gk54:   ldx     b,dir           ;Update direction
  333.         stx     a,dir
  334.         cmp     b
  335.         jrz     gk62
  336.         jr      gk47            ;Direction changed
  337. ;
  338. gk60:   ldx     a,scroly        ;Check scroll on
  339.         ora     a
  340.         jrz     gk70            ;No!
  341. ;
  342. gk62:   mvix    1,cnt2          ;Feed ongoing count
  343. gk64:   ldx     a,lmit          ;Check limit reached
  344.         ora     a
  345.         jrnz    gk70            ;Yes!
  346.         mvix    nscrol,stop     ;Clear stop condition
  347. ;
  348. gk70:   ldx     a,stop          ;If stop condition
  349.         ora     a               ;...then
  350.         jz      getkey          ;...loop until clear
  351.         ret
  352. ;
  353. upln:   ;Advance 24 lines
  354.         ldx     a,lmit          ;Dont advance
  355.         ora     a               ;...if
  356.         rnz                     ;...on limit
  357.         mvix    25,count
  358. upln1:  dcrx    count
  359.         cnz     getln           ;Get next line
  360.         jrnz    upln1           ;Not on limit
  361.         mvix    0,lmit          ;Clear limit if set to
  362.         ret                     ;...dsp 1st/last line
  363. ;
  364. getln:  ;Get next line
  365.         lhld    line            ;Line address
  366.         lxi     b,2000          ;Max length
  367.         ldx     a,dir           ;Check direction
  368.         ora     a
  369.         jrz     upmin
  370. ;
  371. uplus:  mvi     a,lf            ;Search char
  372.         lxi     d,1
  373.         ccir                    ;Find next line
  374.         mvi     a,eomc          ;Reached limit
  375.         cmp     m
  376.         jrnz    upm10           ;No!
  377. upp10:  mvix    1,lmit          ;Return limit
  378.         ret                     ;...set
  379. ;
  380. upmin:  lda     lino+1          ;Check
  381.         ora     a               ;...if
  382.         jrnz    upm02           ;...on
  383.         lda     lino            ;...first
  384.         cpi     1               ;...line
  385.         jrz     upp10           ;Yes!
  386. upm02:  dcx     h
  387.         dcx     h
  388.         mvi     a,lf
  389.         lxi     d,-1
  390.         ccdr                    ;Find previous line
  391.         inx     h
  392.         inx     h
  393. upm10:  shld    line            ;New line address
  394.         mvix    0,lmit          ;Clear limit
  395.         lhld    lino            ;Update
  396.         dad     d               ;...line
  397.         shld    lino            ;...number
  398.         mvi     a,1             ;Return
  399.         ora     a               ;...good
  400.         ret                     ;condition
  401. ;
  402. ;
  403. numout: ;Output line number
  404.         lxiy    linasc          ;Base for string
  405.         lhld    lino            ;Line number
  406.         lxi     d,-10000        ;Ten thousands
  407.         call    toasc           ;Convert to ASCII
  408.         lxi     d,-1000         ;Thousands
  409.         call    toasc
  410.         lxi     d,-100          ;Hundreds
  411.         call    toasc
  412.         lxi     d,-10           ;Tens
  413.         call    toasc
  414.         mov     a,l             ;0 - 9
  415.         adi     '0'
  416.         sty     a,0
  417.         lxi     d,linasc
  418.         mvi     c,printf        ;Print string
  419.         call    bdos
  420.         ret
  421. ;
  422. toasc:  mvi     c,'0'-1
  423. toas1:  inr     c
  424.         dad     d
  425.         jc      toas1
  426.         mov     a,d
  427.         cma
  428.         mov     d,a
  429.         mov     a,e
  430.         cma
  431.         mov     e,a
  432.         inx     d
  433.         dad     d
  434.         sty     c,0
  435.         inxiy
  436.         ret
  437. ;
  438. buflin: ;Prepare line for output
  439.         lbcd    line            ;Current line address
  440.         lhld    linbuf          ;Line buffer address
  441. bufl10: mvix    8,count         ;Tab count
  442. bufl12: ldax    b
  443.         inx     b
  444.         cpi     20h             ;Trap control char
  445.         jrnc    bufl16          ;Not one
  446.         cpi     cr              ;Carriage return?
  447.         jrz     bufl16
  448.         cpi     lf              ;Line feed?
  449.         jrz     bufl16
  450.         cpi     tabc            ;Check if tab
  451.         jrnz    bufl15          ;No!
  452. bufl14: mvi     m,' '           ;Expand tab
  453.         inx     h
  454.         dcrx    count
  455.         jrnz    bufl14
  456.         jr      bufl10
  457. bufl15: mvi     m,'^'           ;Convert control char
  458.         inx     h               ;...to two chars
  459.         ori     40h             ;...for display
  460. bufl16: mov     m,a             ;Normal char
  461.         inx     h
  462.         cpi     lf              ;Line feed
  463.         rz                      ;...ends line
  464.         dcrx    count
  465.         jrz     bufl10
  466.         jr      bufl12
  467. ;
  468. find:   ;Search Input String function
  469.         call    kscan           ;loop until
  470.         lda     ktable          ;...help
  471.         ora     a               ;...key is
  472.         jrnz    find            ;...released
  473.         call    revrse          ;direction
  474.         call    getln           ;adjust line params
  475.         call    revrse
  476.         lxi     d,cbot          ;Bottom line
  477.         ldx     a,dir           ;Check direction
  478.         ora     a
  479.         jrnz    find02
  480.         lxi     d,ctop          ;Top line
  481. find02: mvi     c,printf        ;Clear line
  482.         call    bdos
  483.         lxi     d,dmabuf        ;Buffer for input
  484.         mvi     c,coninf        ;Get input string
  485.         call    bdos
  486.         lda     nc              ;Check char count
  487.         ora     a
  488.         rz                      ;Empty string
  489.         stx     a,count
  490.         lhld    lino            ;Save
  491.         shld    tempn           ;...current line
  492.         lhld    line            ;...params in case
  493.         shld    templ           ;...no match
  494. find10: lbcd    line            ;Begin search loop
  495. find12: mvi     e,0
  496.         lxi     h,rchar
  497. find14: ldax    b
  498.         cmp     m
  499.         inx     h
  500.         inx     b
  501.         jrnz    find16
  502.         inr     e
  503.         mov     a,e
  504.         cmpx    count
  505.         jrnz    find14
  506.         jr      sound           ;String found
  507. find16: cpi     lf
  508.         jrnz    find12
  509.         call    getln
  510.         jrnz    find10
  511. find20: lhld    templ           ;Limit reached
  512.         shld    line            ;...so
  513.         lhld    tempn           ;...restore
  514.         shld    lino            ;...original line
  515.         mvix    0,lmit          ;Clear limit
  516.         ret
  517. ;
  518. sound:  ;Bell
  519.         mvi     c,dciof
  520.         lxi     d,bell
  521.         call    bdos
  522.         mvi     a,1
  523.         ora     a
  524.         ret
  525. ;
  526. revrse: ;Reverse current direction
  527.         mvi     a,plus
  528.         xorx    dir
  529.         stx     a,dir
  530.         ret
  531. ;
  532. clear:  ;Clear Screen
  533.         lxi     d,clr
  534.         mvi     c,printf
  535.         call    bdos
  536.         ret
  537. ;
  538. kscan:  ;Scan C128 Keys
  539.         di
  540.         lxi     h,ktable        ;Key press/change table
  541.         lxi     b,0dc00h        ;Key matrix drives for
  542.         mvi     d,0ffh          ;...C64 keys are
  543.         outp    d               ;...are disabled
  544.         mvi     d,0feh          ;Drive one row
  545.         mvi     e,3             ;...of three
  546. kscn2:  lxi     b,0d02fh        ;Drives for
  547.         outp    d               ;...C128 keys
  548.         lxi     b,0dc01h        ;To read row
  549. kscn3:  inp     a               ;Read keys
  550.         push    h               ;A little delay
  551.         inp     h               ;...helps along the way!
  552.         cmp     h               ;Debounce
  553.         pop     h
  554.         jrnz    kscn3           ;Check again
  555.         cma                     ;Make 1's of presses
  556.         mov     b,m             ;Previous keys
  557.         mov     m,a             ;New keys
  558.         xra     b               ;...gives changes
  559.         ana     m               ;...and pressed changes
  560.         inx     h
  561.         mov     m,a             ;Save pressed changes
  562.         inx     h               ;Now for
  563.         rlcr    d               ;...next row
  564.         dcr     e
  565.         jrnz    kscn2
  566. ;
  567. kchng:  ;Process Changes
  568.         ei
  569.         lxi     h,ktable+2      ;First
  570.         mov     a,m             ;...check
  571.         ani     1               ;...ESC?
  572.         jrz     kchg1
  573.         call    clear           ;Clear screen
  574.         jmp     finis           ;...and exit
  575. kchg1:  mov     a,m
  576.         ani     06h             ;+/- presses?
  577.         inx     h
  578.         jrz     kchg2
  579.         ora     m               ;Force a change
  580.         mov     m,a
  581. kchg2:  inx     h
  582.         inx     h
  583.         mvi     c,3             ;Count
  584. kchg3:  mov     a,m             ;Pressed changes
  585.         cma
  586.         inr     a
  587.         ana     m               ;Extract one change
  588.         jnz     kchg10          ;Found one
  589.         dcx     h               ;Goto next row
  590.         dcx     h
  591.         dcr     c
  592.         jrnz    kchg3
  593.         ret                     ;No changes found
  594. ;
  595. kchg10: ;Decode Change
  596.         lxi     h,dtable        ;Key Decode table
  597.         lxi     d,8
  598. kchg12: dcr     e
  599.         add     a
  600.         jrnc    kchg12
  601.         dad     d
  602.         mvi     e,8
  603. kchg14: dcr     c
  604.         jrz     kchg20
  605.         dad     d
  606.         jr      kchg14
  607. kchg20: mov     a,m             ;Decoded value
  608.         ret
  609. ;
  610. dtable: ;Key Decode Table
  611.         db      help,08,05,tab,02,04,07,01
  612.         db      00,plus,minus,number,enter,06,09,03
  613.         db      alt,10,24,bgnof,endof,00,00,nscrol
  614. ;
  615. ktable: ;Key Press/Change Table: rows 1-3
  616.         db      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  617.         db      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  618.         db      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  619. ;
  620. opnerr: db      cr,lf,'no file$'
  621. rderr:  db      cr,lf,'bad read error$'
  622. ;
  623. sfwd:   db      1bh,3dh,20h,20h,1bh,52h,1bh,3dh,37h,20h,0ah
  624. sbak:   db      1bh,3dh,20h,20h,1bh,45h,0ah
  625. ctop:   db      1bh,3dh,20h,20h,1bh,54h,0ah
  626. cbot:   db      1bh,3dh,37h,20h,1bh,54h,0ah
  627. clr:    db      1ah,0ah
  628. linasc: db      '00000: ',0ah
  629. ;
  630. progend equ     $       ;Used for checksum on code
  631. ;
  632. fend:   ds      2       ;File end address
  633. linbuf: ds      2       ;Line buffer address
  634. line:   ds      2       ;Current line address
  635. lino:   ds      2       ;Current line number
  636. endln:  ds      2       ;Last line number
  637. templ:  ds      2       ;Work area
  638. tempn:  ds      2       ;Work area
  639. pflags: ds      10      ;IX register variables
  640. oldsp:  ds      2       ;Saved stack
  641.         ds      128     ;Program stack
  642. stktop  equ     $
  643. ;
  644. fbegin  equ     800h    ;Text file loads here
  645. ;
  646.         end
  647.